package cn.hxzy.service.impl;

import cn.hxzy.common.CarTypeStatus;
import cn.hxzy.entity.carteam.VehicleInformation;
import cn.hxzy.mapper.VehicleInformationMapper;
import cn.hxzy.service.VehicleInformationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hk
 * @since 2023-06-23
 */
@Service
public class VehicleInformationServiceImpl extends ServiceImpl<VehicleInformationMapper, VehicleInformation> implements VehicleInformationService {

    @Autowired
    private VehicleInformationMapper mapper;

    /**
     * 通过车辆id查询车辆对象
     * @param carId
     * @return
     */
    @Override
    public VehicleInformation selectCarById(String carNum) {
        QueryWrapper<VehicleInformation> wrapper = new QueryWrapper<>();
        //通过车辆编号查询车辆
        wrapper.eq("license_plate_number",carNum);
        VehicleInformation information = mapper.selectOne(wrapper);
        //设置车辆类型
        information.setCarTypeStatusValue(CarTypeStatus.getCarTypeStatusValue(information.getCarType()));
        if (information != null) {
            return information;
        }
        return null;
    }

    @Override
    public boolean save(VehicleInformation entity) {
        return false;
    }
}
